﻿package com.tangchao.client.sdh.view.jiaoFen
{
	import com.tangchao.client.sdh.event.JiaoFenEvent;
	
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;

	public class JiaoFenPanel extends MovieClip
	{
		private var _grid:JiaoFenGrid;
		private var _btJiaoFen:SimpleButton;
		private var _btBuJiao:SimpleButton;
		
		private var _maxNum:int;
		private var _mustBet:Boolean = false;
		public function JiaoFenPanel()
		{
			init();
		}
		
		private function init()
		{
			_grid=getChildByName("mcGrid") as JiaoFenGrid;
			_btBuJiao=getChildByName("btBuJiao") as SimpleButton;
			_btBuJiao.addEventListener(MouseEvent.CLICK,onBuJiaoClick);
		}
		
		/*
		*设置最高可以叫的分
		*/
		public function setMaxNum(value:int, mustBet:Boolean):void
		{
			_mustBet=mustBet;
			_maxNum = value;
			_grid.maxNum=value;
			_btBuJiao.visible = !mustBet;
		}
		
		public function doAutoBet():void
		{
			var evt:JiaoFenEvent=new JiaoFenEvent();
			evt.isJiao= _mustBet;
			evt.value = _maxNum;
			dispatchEvent(evt);
		}
		
		private function onBuJiaoClick(e:MouseEvent)
		{
			var evt:JiaoFenEvent=new JiaoFenEvent();
			evt.isJiao=false;
			dispatchEvent(evt);
		}
	}
}